﻿package app
{
    import org.puremvc.interfaces.*;
    import org.puremvc.patterns.proxy.*;
    import org.puremvc.patterns.facade.*;

    import app.view.*;
    import app.controller.*;

    import org.puremvc.patterns.observer.Notification;
    
    import flash.display.DisplayObject;
    
    import org.puremvc.patterns.observer.Observer;    
    public class ApplicationFacade extends Facade
    {
        
        // командные нотификации
        public static const CMD_STARTUP:String              = "cmdStartup";
        public static const CMD_START_SITE:String              = "CMD_START_SITE";
        public static const CMD_CHANGE_SECTION:String              = "CMD_CHANGE_SECTION";
        public static const CMD_CHANGE_LANG:String              = "CMD_CHANGE_LANG";
        public static const CMD_GO_MAIN:String              = "CMD_GO_MAIN";
        public static const CMD_GO_BACK:String              = "CMD_GO_BACK";
		
		// 
		public static const STAGE_RESIZE:String              = "STAGE_RESIZE";
		public static const START_SITE:String              = "START_SITE";
        public static const CHANGE_SECTION:String              = "CHANGE_SECTION";
        public static const CHANGE_LANG:String              = "CHANGE_LANG";
		

        /**
         * Startup method 
         */
        public function startup( root:DisplayObject ) : void 
		{
            notifyObservers( new Notification( ApplicationFacade.CMD_STARTUP, root ) );
        }
                
        /**
         * Register Commands with the Controller 
         */
        override protected function initializeController( ) : void 
        {
            super.initializeController();           
            registerCommand( CMD_STARTUP,       	StartupCommand);
            registerCommand( CMD_START_SITE,       	StartSiteCommand);
            registerCommand( CMD_CHANGE_SECTION,    ChangeSectionCommand);
            registerCommand( CMD_CHANGE_LANG,       ChangeLanguageCommand);
            registerCommand( CMD_GO_MAIN,       	GoMainCommand);
            registerCommand( CMD_GO_BACK,       	GoBackCommand);
        };
        
        
        /**
         * Singleton ApplicationFacade Factory Method
         */
        public static function getInstance() : ApplicationFacade 
        {
            if ( instance == null ) instance = new ApplicationFacade( );
            return instance as ApplicationFacade;
        };
        
    };
};
